tiny-c operators.txt - lrb - 1/22/9 Operators are listed in order of precedence, from highest to lowest. Use parentheses to override evaluation order if needed. If terms involve operators of equal precedence, left to right evaluation is used. Exception: x=y=z. Here, z's value goes into y and then y's value goes into x (i.e. assignment is done right to left). ------------------------------------------------------------------------------------ ++x This is the increment unary operator and is equivalent to x=x+1. --x This is the decrement unary operator and is equivalent to x=x-1. !x This is the unary "not" operator. If x is 0, !x is 1 and if x is not 0, !x is 0. +x When used alone to the left of a variable, the plus sign is called a unary plus. It has no effect and is used sometimes for readability. -x When used alone to the left of a variable, the minus sign is called a unary minus. The value of -x is the negative of the value of x. ------------------------------------------------------------------------------------ x*y Multiplication. x/y Division. Any remainder is discarded. 7/2 equals 3. -7/2 equals -3. x%y Remainder. The remainder when x is divided by y. 7%2 equals 1. -7%2 equals -1. ------------------------------------------------------------------------------------ x+y Addition. x-y Subtraction. ------------------------------------------------------------------------------------ xy Greater than. If x is greater than y, value is 1. Otherwise, value is 0. x<=y Less than or equal. If x is less than or equal to y, value is 1. Otherwise, value is 0. x>=y Greater than or equal. If x is greater than or equal to y, value is 1. Otherwise, value is 0. x!=y Not equal. If x is not equal to y, value is 1. Otherwise, value is 0. x==y Equal. If x is equal to y, value is 1. Otherwise, value is 0. ------------------------------------------------------------------------------------ x=y Assignment. The value y is assigned to x. Then, the expression x=y assumes the value of y. ------------------------------------------------------------------------------------